package com.fsc.mapper;

import com.fsc.entity.domain.AnnRepoNews;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fsc.entity.dto.NewsDTO;
import com.fsc.entity.dto.NewsEditDTO;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
* @author 86183
* @description 针对表【ann_repo_news(通知、公告、新闻表)】的数据库操作Mapper
* @createDate 2024-06-02 13:15:21
* @Entity com.fsc.domain.AnnRepoNews
*/
@Mapper
public interface AnnRepoNewsMapper extends BaseMapper<AnnRepoNews> {
    @Select("SELECT * " +
            "FROM ann_repo_news " +
            "WHERE school_id = #{schoolId} AND privace = #{privace} " +
            "AND status = #{status} AND type = #{type}")
    List<AnnRepoNews> getNews(NewsDTO newsDTO);

    @Select("SELECT * " +
            "FROM ann_repo_news " +
            "WHERE school_id = #{schoolId} AND author_id = #{authorId} " +
            "AND status = #{status} ")
    List<AnnRepoNews> getAllNews(NewsEditDTO newsEditDTO);

    @Delete("DELETE FROM ann_repo_news " +
            "WHERE id = #{id}")
    void deleteNews(long id);

    @Update("UPDATE ann_repo_news SET status = #{status} WHERE id = #{id}")
    void updateStatus(long id,int status);

    @Update("UPDATE ann_repo_news SET privace = #{privace} WHERE id = #{id}")
    void updatePrivace(long id,int privace);

    @Select("SELECT * FROM ann_repo_news WHERE id = #{id}")
    AnnRepoNews selectById(long id);
}




